//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal abstract class CellValueRecord : CellRecord
    {
        protected CellValueRecord(Cell cell, BiffWriterWorkbookContext record): base (cell, record)
        {
            Contract.Requires(cell != null);
            this._row = (ushort) cell.Row.Index;
            _column = (ushort) cell.Column.Index;
        }

        protected CellValueRecord()
        {
            
        }

        protected abstract object GetValue(BiffReaderWorkbookContext context);

        internal override void ApplyCore(BiffReaderWorksheetContext context)
        {
            Cell cell = context.Worksheet.EnsurePromotedCell(Row, Column);
            object value = GetValue(context.WorkbookContext);
            cell.setRawValue(value);
            //cell.Value = value;
        }
    }
}